
app.service("load",function($rootScope){
    // $scope.loadStatus="";
   var load={
        "start":function(){
            console.log(111);
           $rootScope.loadStatus=true;
            // $scope.$emit("loadStatus",loadStatus)
        },
        "end":function(){
           $rootScope.loadStatus=false;
            // $scope.$emit("loadStatus",loadStatus)
        }
    }
    return load;
})
app.service("toast",function($rootScope,$timeout,$animate){
    return function(msg,callBack){
        var el=angular.element(document.querySelector(".toast"))
        el.removeClass("hidden");
        el.find("div")[0].innerHTML=msg;
        // $rootScope.toastMsg=msg;
        // console.log($rootScope.toastMsg);
        
        $timeout(function(){
            el.addClass("hidden");
            if(callBack){
                callBack();
            }  
        },1000)
    }
})
app.service("service",function($rootScope,$http){
    return{
        "get":function(url,data,successCall,errorCall){
            console.log(arguments);
            $rootScope.loadStatus=true;
            $http({
                "method":"get",
                "url":url,
                "data":data
            })
            .success(function(data){
                
                     successCall(data)
                    $rootScope.loadStatus=false;
                
            })
            .error(function(data){
                $rootScope.loadStatus=false;
                errorCall(data)
            })
        },
        "post":function(selector,url,successCall,errorCall){
             $rootScope.loadStatus=true;
            $(selector).ajaxSubmit({
                type: "post",
                dataType: "json",
                url:url,
                success:function(data){
                    console.log(data);
                    successCall(data);
                    $rootScope.loadStatus=false;
                },
                fail:function(data){
                    $rootScope.loadStatus=false;
                    errorCall(data);
                }
            })
            $rootScope.loadStatus=false;  
        }
    }
})